﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;

using CNCSoft.EWinform;
using CNCSoft.EWinform.ControlUtils;
using CNCSoft.EWinform.ERPApps;
using CNCSoft.EWinform.AGrid;
using CNCSoft.EData;

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

using System.Threading;
using System.Globalization;

using Common;

namespace CNCSoft.ErpApps.TMS {

	/// <summary>
	/// Summary description for TienMatPhieuThu.
	/// </summary>
	public class TienMatPhieuThu : System.Windows.Forms.Form {
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label10;
		internal System.Windows.Forms.Panel pnlButtons;
		internal System.Windows.Forms.Button cmdModify;
		internal System.Windows.Forms.Button cmdCancel;
		internal System.Windows.Forms.Button cmdPrint;
		internal System.Windows.Forms.Button cmdView;
		internal System.Windows.Forms.Button cmdDelete;
        internal System.Windows.Forms.Button cmdAddNew;
		private System.Windows.Forms.ComboBox cboDonViNopTien;
		private System.Windows.Forms.TextBox txtHoTenNguoiNopTien;
		private System.Windows.Forms.TextBox txtDienGiai;
		private System.Windows.Forms.TextBox txtChungTuKemTheo;
		private System.Windows.Forms.TextBox txtSoChungTu;
        private System.Windows.Forms.ComboBox cboLyDoThu;
		private System.Windows.Forms.Button cmdXemTK;
		internal System.Windows.Forms.Button cmdUpdate;
		private System.Windows.Forms.TextBox txtDiaChi;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.ToolTip toolTip1;
		private System.Windows.Forms.ErrorProvider ep;
		private System.Windows.Forms.Label lblStatus;
		private System.Windows.Forms.Button cmdLookupDVNopTiep;
		private System.Windows.Forms.Panel pnlNevigator;
		internal System.Windows.Forms.Button cmdMovePrevious;
		internal System.Windows.Forms.Button cmdMoveFirst;
		internal System.Windows.Forms.Button cmdMoveLast;
		internal System.Windows.Forms.Button cmdMoveNext;
		private CNCSoft.EWinform.ValidText txtNgayChungTu;
        private System.Windows.Forms.TextBox txtSoTienUSD;
		private System.Windows.Forms.Label lblRecordInfo;
		private System.Windows.Forms.Panel pnlBottom;
		private System.Windows.Forms.PictureBox picboxNote;
        private System.Windows.Forms.PictureBox picboxHelp;
        private TextBox txtSoTien;
        private Label label11;
        private TextBox txtTigia;
        private Label label7;
        private DataGrid dgridChiTietPT;
        private TextBox txtSoTienDiscount;
        private Label label12;
        private TextBox txtPhantramDiscount;
        private Label label13;
        private TextBox txtThucThu;
        private Label label14;
		private System.ComponentModel.IContainer components;

		public TienMatPhieuThu()
		{
			//
			// Required for Windows Form Designer support
			//

            // Sets the UI culture to VietNamese (VietNam) / English
            if (GlobalVariable.WSInfo.Language == "Tiếng Việt")
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("vi-VN");
            else if (GlobalVariable.WSInfo.Language == "English")
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");

			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TienMatPhieuThu));
            this.label1 = new System.Windows.Forms.Label();
            this.cboDonViNopTien = new System.Windows.Forms.ComboBox();
            this.label2 = new System.Windows.Forms.Label();
            this.txtHoTenNguoiNopTien = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.txtDienGiai = new System.Windows.Forms.TextBox();
            this.txtChungTuKemTheo = new System.Windows.Forms.TextBox();
            this.label5 = new System.Windows.Forms.Label();
            this.label8 = new System.Windows.Forms.Label();
            this.txtSoChungTu = new System.Windows.Forms.TextBox();
            this.label9 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.label10 = new System.Windows.Forms.Label();
            this.cboLyDoThu = new System.Windows.Forms.ComboBox();
            this.pnlButtons = new System.Windows.Forms.Panel();
            this.cmdModify = new System.Windows.Forms.Button();
            this.cmdCancel = new System.Windows.Forms.Button();
            this.cmdPrint = new System.Windows.Forms.Button();
            this.cmdView = new System.Windows.Forms.Button();
            this.cmdDelete = new System.Windows.Forms.Button();
            this.cmdAddNew = new System.Windows.Forms.Button();
            this.cmdUpdate = new System.Windows.Forms.Button();
            this.cmdXemTK = new System.Windows.Forms.Button();
            this.txtDiaChi = new System.Windows.Forms.TextBox();
            this.label6 = new System.Windows.Forms.Label();
            this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
            this.picboxNote = new System.Windows.Forms.PictureBox();
            this.picboxHelp = new System.Windows.Forms.PictureBox();
            this.cmdLookupDVNopTiep = new System.Windows.Forms.Button();
            this.txtSoTien = new System.Windows.Forms.TextBox();
            this.dgridChiTietPT = new System.Windows.Forms.DataGrid();
            this.txtThucThu = new System.Windows.Forms.TextBox();
            this.lblStatus = new System.Windows.Forms.Label();
            this.pnlBottom = new System.Windows.Forms.Panel();
            this.pnlNevigator = new System.Windows.Forms.Panel();
            this.cmdMoveFirst = new System.Windows.Forms.Button();
            this.cmdMovePrevious = new System.Windows.Forms.Button();
            this.cmdMoveNext = new System.Windows.Forms.Button();
            this.cmdMoveLast = new System.Windows.Forms.Button();
            this.lblRecordInfo = new System.Windows.Forms.Label();
            this.txtNgayChungTu = new CNCSoft.EWinform.ValidText();
            this.txtSoTienUSD = new System.Windows.Forms.TextBox();
            this.txtTigia = new System.Windows.Forms.TextBox();
            this.label7 = new System.Windows.Forms.Label();
            this.label11 = new System.Windows.Forms.Label();
            this.txtSoTienDiscount = new System.Windows.Forms.TextBox();
            this.label12 = new System.Windows.Forms.Label();
            this.txtPhantramDiscount = new System.Windows.Forms.TextBox();
            this.label13 = new System.Windows.Forms.Label();
            this.label14 = new System.Windows.Forms.Label();
            this.ep = new System.Windows.Forms.ErrorProvider(this.components);
            this.pnlButtons.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.picboxNote)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.picboxHelp)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.dgridChiTietPT)).BeginInit();
            this.pnlBottom.SuspendLayout();
            this.pnlNevigator.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.ep)).BeginInit();
            this.SuspendLayout();
            // 
            // label1
            // 
            resources.ApplyResources(this.label1, "label1");
            this.ep.SetError(this.label1, resources.GetString("label1.Error"));
            this.ep.SetIconAlignment(this.label1, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label1.IconAlignment"))));
            this.ep.SetIconPadding(this.label1, ((int)(resources.GetObject("label1.IconPadding"))));
            this.label1.Name = "label1";
            this.toolTip1.SetToolTip(this.label1, resources.GetString("label1.ToolTip"));
            // 
            // cboDonViNopTien
            // 
            resources.ApplyResources(this.cboDonViNopTien, "cboDonViNopTien");
            this.ep.SetError(this.cboDonViNopTien, resources.GetString("cboDonViNopTien.Error"));
            this.ep.SetIconAlignment(this.cboDonViNopTien, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cboDonViNopTien.IconAlignment"))));
            this.ep.SetIconPadding(this.cboDonViNopTien, ((int)(resources.GetObject("cboDonViNopTien.IconPadding"))));
            this.cboDonViNopTien.Name = "cboDonViNopTien";
            this.toolTip1.SetToolTip(this.cboDonViNopTien, resources.GetString("cboDonViNopTien.ToolTip"));
            this.cboDonViNopTien.SelectedIndexChanged += new System.EventHandler(this.cboDonViNopTien_SelectedIndexChanged);
            this.cboDonViNopTien.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cboDonViNopTien_KeyDown);
            // 
            // label2
            // 
            resources.ApplyResources(this.label2, "label2");
            this.ep.SetError(this.label2, resources.GetString("label2.Error"));
            this.ep.SetIconAlignment(this.label2, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label2.IconAlignment"))));
            this.ep.SetIconPadding(this.label2, ((int)(resources.GetObject("label2.IconPadding"))));
            this.label2.Name = "label2";
            this.toolTip1.SetToolTip(this.label2, resources.GetString("label2.ToolTip"));
            // 
            // txtHoTenNguoiNopTien
            // 
            resources.ApplyResources(this.txtHoTenNguoiNopTien, "txtHoTenNguoiNopTien");
            this.ep.SetError(this.txtHoTenNguoiNopTien, resources.GetString("txtHoTenNguoiNopTien.Error"));
            this.ep.SetIconAlignment(this.txtHoTenNguoiNopTien, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtHoTenNguoiNopTien.IconAlignment"))));
            this.ep.SetIconPadding(this.txtHoTenNguoiNopTien, ((int)(resources.GetObject("txtHoTenNguoiNopTien.IconPadding"))));
            this.txtHoTenNguoiNopTien.Name = "txtHoTenNguoiNopTien";
            this.toolTip1.SetToolTip(this.txtHoTenNguoiNopTien, resources.GetString("txtHoTenNguoiNopTien.ToolTip"));
            // 
            // label3
            // 
            resources.ApplyResources(this.label3, "label3");
            this.ep.SetError(this.label3, resources.GetString("label3.Error"));
            this.ep.SetIconAlignment(this.label3, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label3.IconAlignment"))));
            this.ep.SetIconPadding(this.label3, ((int)(resources.GetObject("label3.IconPadding"))));
            this.label3.Name = "label3";
            this.toolTip1.SetToolTip(this.label3, resources.GetString("label3.ToolTip"));
            // 
            // txtDienGiai
            // 
            resources.ApplyResources(this.txtDienGiai, "txtDienGiai");
            this.ep.SetError(this.txtDienGiai, resources.GetString("txtDienGiai.Error"));
            this.ep.SetIconAlignment(this.txtDienGiai, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtDienGiai.IconAlignment"))));
            this.ep.SetIconPadding(this.txtDienGiai, ((int)(resources.GetObject("txtDienGiai.IconPadding"))));
            this.txtDienGiai.Name = "txtDienGiai";
            this.txtDienGiai.Tag = "<LyDoThu> của <TenDonVi>";
            this.toolTip1.SetToolTip(this.txtDienGiai, resources.GetString("txtDienGiai.ToolTip"));
            this.txtDienGiai.Leave += new System.EventHandler(this.txtDienGiai_Leave);
            this.txtDienGiai.Validated += new System.EventHandler(this.txtDienGiai_Validated);
            // 
            // txtChungTuKemTheo
            // 
            resources.ApplyResources(this.txtChungTuKemTheo, "txtChungTuKemTheo");
            this.ep.SetError(this.txtChungTuKemTheo, resources.GetString("txtChungTuKemTheo.Error"));
            this.ep.SetIconAlignment(this.txtChungTuKemTheo, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtChungTuKemTheo.IconAlignment"))));
            this.ep.SetIconPadding(this.txtChungTuKemTheo, ((int)(resources.GetObject("txtChungTuKemTheo.IconPadding"))));
            this.txtChungTuKemTheo.Name = "txtChungTuKemTheo";
            this.toolTip1.SetToolTip(this.txtChungTuKemTheo, resources.GetString("txtChungTuKemTheo.ToolTip"));
            // 
            // label5
            // 
            resources.ApplyResources(this.label5, "label5");
            this.ep.SetError(this.label5, resources.GetString("label5.Error"));
            this.ep.SetIconAlignment(this.label5, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label5.IconAlignment"))));
            this.ep.SetIconPadding(this.label5, ((int)(resources.GetObject("label5.IconPadding"))));
            this.label5.Name = "label5";
            this.toolTip1.SetToolTip(this.label5, resources.GetString("label5.ToolTip"));
            // 
            // label8
            // 
            resources.ApplyResources(this.label8, "label8");
            this.ep.SetError(this.label8, resources.GetString("label8.Error"));
            this.ep.SetIconAlignment(this.label8, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label8.IconAlignment"))));
            this.ep.SetIconPadding(this.label8, ((int)(resources.GetObject("label8.IconPadding"))));
            this.label8.Name = "label8";
            this.toolTip1.SetToolTip(this.label8, resources.GetString("label8.ToolTip"));
            // 
            // txtSoChungTu
            // 
            resources.ApplyResources(this.txtSoChungTu, "txtSoChungTu");
            this.ep.SetError(this.txtSoChungTu, resources.GetString("txtSoChungTu.Error"));
            this.txtSoChungTu.ForeColor = System.Drawing.Color.ForestGreen;
            this.ep.SetIconAlignment(this.txtSoChungTu, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtSoChungTu.IconAlignment"))));
            this.ep.SetIconPadding(this.txtSoChungTu, ((int)(resources.GetObject("txtSoChungTu.IconPadding"))));
            this.txtSoChungTu.Name = "txtSoChungTu";
            this.txtSoChungTu.TabStop = false;
            this.toolTip1.SetToolTip(this.txtSoChungTu, resources.GetString("txtSoChungTu.ToolTip"));
            // 
            // label9
            // 
            resources.ApplyResources(this.label9, "label9");
            this.ep.SetError(this.label9, resources.GetString("label9.Error"));
            this.ep.SetIconAlignment(this.label9, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label9.IconAlignment"))));
            this.ep.SetIconPadding(this.label9, ((int)(resources.GetObject("label9.IconPadding"))));
            this.label9.Name = "label9";
            this.toolTip1.SetToolTip(this.label9, resources.GetString("label9.ToolTip"));
            // 
            // label4
            // 
            resources.ApplyResources(this.label4, "label4");
            this.ep.SetError(this.label4, resources.GetString("label4.Error"));
            this.ep.SetIconAlignment(this.label4, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label4.IconAlignment"))));
            this.ep.SetIconPadding(this.label4, ((int)(resources.GetObject("label4.IconPadding"))));
            this.label4.Name = "label4";
            this.toolTip1.SetToolTip(this.label4, resources.GetString("label4.ToolTip"));
            // 
            // label10
            // 
            resources.ApplyResources(this.label10, "label10");
            this.ep.SetError(this.label10, resources.GetString("label10.Error"));
            this.ep.SetIconAlignment(this.label10, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label10.IconAlignment"))));
            this.ep.SetIconPadding(this.label10, ((int)(resources.GetObject("label10.IconPadding"))));
            this.label10.Name = "label10";
            this.toolTip1.SetToolTip(this.label10, resources.GetString("label10.ToolTip"));
            // 
            // cboLyDoThu
            // 
            resources.ApplyResources(this.cboLyDoThu, "cboLyDoThu");
            this.ep.SetError(this.cboLyDoThu, resources.GetString("cboLyDoThu.Error"));
            this.ep.SetIconAlignment(this.cboLyDoThu, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cboLyDoThu.IconAlignment"))));
            this.ep.SetIconPadding(this.cboLyDoThu, ((int)(resources.GetObject("cboLyDoThu.IconPadding"))));
            this.cboLyDoThu.Name = "cboLyDoThu";
            this.toolTip1.SetToolTip(this.cboLyDoThu, resources.GetString("cboLyDoThu.ToolTip"));
            this.cboLyDoThu.Validated += new System.EventHandler(this.cboLyDoThu_Validated);
            // 
            // pnlButtons
            // 
            resources.ApplyResources(this.pnlButtons, "pnlButtons");
            this.pnlButtons.Controls.Add(this.cmdModify);
            this.pnlButtons.Controls.Add(this.cmdCancel);
            this.pnlButtons.Controls.Add(this.cmdPrint);
            this.pnlButtons.Controls.Add(this.cmdView);
            this.pnlButtons.Controls.Add(this.cmdDelete);
            this.pnlButtons.Controls.Add(this.cmdAddNew);
            this.pnlButtons.Controls.Add(this.cmdUpdate);
            this.ep.SetError(this.pnlButtons, resources.GetString("pnlButtons.Error"));
            this.ep.SetIconAlignment(this.pnlButtons, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("pnlButtons.IconAlignment"))));
            this.ep.SetIconPadding(this.pnlButtons, ((int)(resources.GetObject("pnlButtons.IconPadding"))));
            this.pnlButtons.Name = "pnlButtons";
            this.toolTip1.SetToolTip(this.pnlButtons, resources.GetString("pnlButtons.ToolTip"));
            // 
            // cmdModify
            // 
            resources.ApplyResources(this.cmdModify, "cmdModify");
            this.cmdModify.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdModify, resources.GetString("cmdModify.Error"));
            this.cmdModify.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdModify, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdModify.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdModify, ((int)(resources.GetObject("cmdModify.IconPadding"))));
            this.cmdModify.Name = "cmdModify";
            this.toolTip1.SetToolTip(this.cmdModify, resources.GetString("cmdModify.ToolTip"));
            this.cmdModify.Click += new System.EventHandler(this.cmdModify_Click);
            // 
            // cmdCancel
            // 
            resources.ApplyResources(this.cmdCancel, "cmdCancel");
            this.cmdCancel.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdCancel, resources.GetString("cmdCancel.Error"));
            this.cmdCancel.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdCancel, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdCancel.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdCancel, ((int)(resources.GetObject("cmdCancel.IconPadding"))));
            this.cmdCancel.Name = "cmdCancel";
            this.toolTip1.SetToolTip(this.cmdCancel, resources.GetString("cmdCancel.ToolTip"));
            this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
            // 
            // cmdPrint
            // 
            resources.ApplyResources(this.cmdPrint, "cmdPrint");
            this.cmdPrint.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdPrint, resources.GetString("cmdPrint.Error"));
            this.cmdPrint.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdPrint, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdPrint.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdPrint, ((int)(resources.GetObject("cmdPrint.IconPadding"))));
            this.cmdPrint.Name = "cmdPrint";
            this.toolTip1.SetToolTip(this.cmdPrint, resources.GetString("cmdPrint.ToolTip"));
            this.cmdPrint.Click += new System.EventHandler(this.cmdPrint_Click);
            // 
            // cmdView
            // 
            resources.ApplyResources(this.cmdView, "cmdView");
            this.cmdView.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdView, resources.GetString("cmdView.Error"));
            this.cmdView.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdView, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdView.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdView, ((int)(resources.GetObject("cmdView.IconPadding"))));
            this.cmdView.Name = "cmdView";
            this.toolTip1.SetToolTip(this.cmdView, resources.GetString("cmdView.ToolTip"));
            this.cmdView.Click += new System.EventHandler(this.cmdView_Click);
            // 
            // cmdDelete
            // 
            resources.ApplyResources(this.cmdDelete, "cmdDelete");
            this.cmdDelete.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdDelete, resources.GetString("cmdDelete.Error"));
            this.cmdDelete.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdDelete, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdDelete.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdDelete, ((int)(resources.GetObject("cmdDelete.IconPadding"))));
            this.cmdDelete.Name = "cmdDelete";
            this.toolTip1.SetToolTip(this.cmdDelete, resources.GetString("cmdDelete.ToolTip"));
            this.cmdDelete.Click += new System.EventHandler(this.cmdDelete_Click);
            // 
            // cmdAddNew
            // 
            resources.ApplyResources(this.cmdAddNew, "cmdAddNew");
            this.cmdAddNew.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdAddNew, resources.GetString("cmdAddNew.Error"));
            this.cmdAddNew.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdAddNew, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdAddNew.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdAddNew, ((int)(resources.GetObject("cmdAddNew.IconPadding"))));
            this.cmdAddNew.Name = "cmdAddNew";
            this.toolTip1.SetToolTip(this.cmdAddNew, resources.GetString("cmdAddNew.ToolTip"));
            this.cmdAddNew.Click += new System.EventHandler(this.cmdAddNew_Click);
            // 
            // cmdUpdate
            // 
            resources.ApplyResources(this.cmdUpdate, "cmdUpdate");
            this.cmdUpdate.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdUpdate, resources.GetString("cmdUpdate.Error"));
            this.cmdUpdate.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdUpdate, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdUpdate.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdUpdate, ((int)(resources.GetObject("cmdUpdate.IconPadding"))));
            this.cmdUpdate.Name = "cmdUpdate";
            this.toolTip1.SetToolTip(this.cmdUpdate, resources.GetString("cmdUpdate.ToolTip"));
            this.cmdUpdate.Click += new System.EventHandler(this.cmdSave_Click);
            // 
            // cmdXemTK
            // 
            resources.ApplyResources(this.cmdXemTK, "cmdXemTK");
            this.cmdXemTK.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdXemTK, resources.GetString("cmdXemTK.Error"));
            this.cmdXemTK.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdXemTK, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdXemTK.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdXemTK, ((int)(resources.GetObject("cmdXemTK.IconPadding"))));
            this.cmdXemTK.Name = "cmdXemTK";
            this.cmdXemTK.TabStop = false;
            this.toolTip1.SetToolTip(this.cmdXemTK, resources.GetString("cmdXemTK.ToolTip"));
            this.cmdXemTK.Click += new System.EventHandler(this.cmdXemTK_Click);
            // 
            // txtDiaChi
            // 
            resources.ApplyResources(this.txtDiaChi, "txtDiaChi");
            this.ep.SetError(this.txtDiaChi, resources.GetString("txtDiaChi.Error"));
            this.ep.SetIconAlignment(this.txtDiaChi, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtDiaChi.IconAlignment"))));
            this.ep.SetIconPadding(this.txtDiaChi, ((int)(resources.GetObject("txtDiaChi.IconPadding"))));
            this.txtDiaChi.Name = "txtDiaChi";
            this.toolTip1.SetToolTip(this.txtDiaChi, resources.GetString("txtDiaChi.ToolTip"));
            // 
            // label6
            // 
            resources.ApplyResources(this.label6, "label6");
            this.ep.SetError(this.label6, resources.GetString("label6.Error"));
            this.ep.SetIconAlignment(this.label6, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label6.IconAlignment"))));
            this.ep.SetIconPadding(this.label6, ((int)(resources.GetObject("label6.IconPadding"))));
            this.label6.Name = "label6";
            this.toolTip1.SetToolTip(this.label6, resources.GetString("label6.ToolTip"));
            // 
            // picboxNote
            // 
            resources.ApplyResources(this.picboxNote, "picboxNote");
            this.picboxNote.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.picboxNote, resources.GetString("picboxNote.Error"));
            this.ep.SetIconAlignment(this.picboxNote, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("picboxNote.IconAlignment"))));
            this.ep.SetIconPadding(this.picboxNote, ((int)(resources.GetObject("picboxNote.IconPadding"))));
            this.picboxNote.Name = "picboxNote";
            this.picboxNote.TabStop = false;
            this.toolTip1.SetToolTip(this.picboxNote, resources.GetString("picboxNote.ToolTip"));
            this.picboxNote.Click += new System.EventHandler(this.cmdNote_Click);
            // 
            // picboxHelp
            // 
            resources.ApplyResources(this.picboxHelp, "picboxHelp");
            this.picboxHelp.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.picboxHelp, resources.GetString("picboxHelp.Error"));
            this.ep.SetIconAlignment(this.picboxHelp, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("picboxHelp.IconAlignment"))));
            this.ep.SetIconPadding(this.picboxHelp, ((int)(resources.GetObject("picboxHelp.IconPadding"))));
            this.picboxHelp.Name = "picboxHelp";
            this.picboxHelp.TabStop = false;
            this.toolTip1.SetToolTip(this.picboxHelp, resources.GetString("picboxHelp.ToolTip"));
            this.picboxHelp.Click += new System.EventHandler(this.picboxHelp_Click);
            // 
            // cmdLookupDVNopTiep
            // 
            resources.ApplyResources(this.cmdLookupDVNopTiep, "cmdLookupDVNopTiep");
            this.cmdLookupDVNopTiep.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdLookupDVNopTiep, resources.GetString("cmdLookupDVNopTiep.Error"));
            this.cmdLookupDVNopTiep.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdLookupDVNopTiep, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdLookupDVNopTiep.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdLookupDVNopTiep, ((int)(resources.GetObject("cmdLookupDVNopTiep.IconPadding"))));
            this.cmdLookupDVNopTiep.Name = "cmdLookupDVNopTiep";
            this.cmdLookupDVNopTiep.TabStop = false;
            this.toolTip1.SetToolTip(this.cmdLookupDVNopTiep, resources.GetString("cmdLookupDVNopTiep.ToolTip"));
            this.cmdLookupDVNopTiep.Click += new System.EventHandler(this.cmdLookupDVNopTiep_Click);
            // 
            // txtSoTien
            // 
            resources.ApplyResources(this.txtSoTien, "txtSoTien");
            this.txtSoTien.BackColor = System.Drawing.Color.PaleGoldenrod;
            this.ep.SetError(this.txtSoTien, resources.GetString("txtSoTien.Error"));
            this.txtSoTien.ForeColor = System.Drawing.Color.IndianRed;
            this.ep.SetIconAlignment(this.txtSoTien, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtSoTien.IconAlignment"))));
            this.ep.SetIconPadding(this.txtSoTien, ((int)(resources.GetObject("txtSoTien.IconPadding"))));
            this.txtSoTien.Name = "txtSoTien";
            this.toolTip1.SetToolTip(this.txtSoTien, resources.GetString("txtSoTien.ToolTip"));
            this.txtSoTien.Validated += new System.EventHandler(this.txtSoTien_Validated);
            // 
            // dgridChiTietPT
            // 
            resources.ApplyResources(this.dgridChiTietPT, "dgridChiTietPT");
            this.dgridChiTietPT.AllowSorting = false;
            this.dgridChiTietPT.CaptionVisible = false;
            this.dgridChiTietPT.DataMember = "";
            this.ep.SetError(this.dgridChiTietPT, resources.GetString("dgridChiTietPT.Error"));
            this.dgridChiTietPT.HeaderForeColor = System.Drawing.SystemColors.ControlText;
            this.ep.SetIconAlignment(this.dgridChiTietPT, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("dgridChiTietPT.IconAlignment"))));
            this.ep.SetIconPadding(this.dgridChiTietPT, ((int)(resources.GetObject("dgridChiTietPT.IconPadding"))));
            this.dgridChiTietPT.Name = "dgridChiTietPT";
            this.toolTip1.SetToolTip(this.dgridChiTietPT, resources.GetString("dgridChiTietPT.ToolTip"));
            // 
            // txtThucThu
            // 
            resources.ApplyResources(this.txtThucThu, "txtThucThu");
            this.txtThucThu.BackColor = System.Drawing.Color.PaleGoldenrod;
            this.ep.SetError(this.txtThucThu, resources.GetString("txtThucThu.Error"));
            this.txtThucThu.ForeColor = System.Drawing.Color.IndianRed;
            this.ep.SetIconAlignment(this.txtThucThu, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtThucThu.IconAlignment"))));
            this.ep.SetIconPadding(this.txtThucThu, ((int)(resources.GetObject("txtThucThu.IconPadding"))));
            this.txtThucThu.Name = "txtThucThu";
            this.toolTip1.SetToolTip(this.txtThucThu, resources.GetString("txtThucThu.ToolTip"));
            // 
            // lblStatus
            // 
            resources.ApplyResources(this.lblStatus, "lblStatus");
            this.ep.SetError(this.lblStatus, resources.GetString("lblStatus.Error"));
            this.ep.SetIconAlignment(this.lblStatus, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("lblStatus.IconAlignment"))));
            this.ep.SetIconPadding(this.lblStatus, ((int)(resources.GetObject("lblStatus.IconPadding"))));
            this.lblStatus.Name = "lblStatus";
            this.toolTip1.SetToolTip(this.lblStatus, resources.GetString("lblStatus.ToolTip"));
            // 
            // pnlBottom
            // 
            resources.ApplyResources(this.pnlBottom, "pnlBottom");
            this.pnlBottom.Controls.Add(this.picboxNote);
            this.pnlBottom.Controls.Add(this.picboxHelp);
            this.pnlBottom.Controls.Add(this.lblStatus);
            this.pnlBottom.Controls.Add(this.pnlNevigator);
            this.ep.SetError(this.pnlBottom, resources.GetString("pnlBottom.Error"));
            this.ep.SetIconAlignment(this.pnlBottom, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("pnlBottom.IconAlignment"))));
            this.ep.SetIconPadding(this.pnlBottom, ((int)(resources.GetObject("pnlBottom.IconPadding"))));
            this.pnlBottom.Name = "pnlBottom";
            this.toolTip1.SetToolTip(this.pnlBottom, resources.GetString("pnlBottom.ToolTip"));
            // 
            // pnlNevigator
            // 
            resources.ApplyResources(this.pnlNevigator, "pnlNevigator");
            this.pnlNevigator.Controls.Add(this.cmdMoveFirst);
            this.pnlNevigator.Controls.Add(this.cmdMovePrevious);
            this.pnlNevigator.Controls.Add(this.cmdMoveNext);
            this.pnlNevigator.Controls.Add(this.cmdMoveLast);
            this.pnlNevigator.Controls.Add(this.lblRecordInfo);
            this.ep.SetError(this.pnlNevigator, resources.GetString("pnlNevigator.Error"));
            this.ep.SetIconAlignment(this.pnlNevigator, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("pnlNevigator.IconAlignment"))));
            this.ep.SetIconPadding(this.pnlNevigator, ((int)(resources.GetObject("pnlNevigator.IconPadding"))));
            this.pnlNevigator.Name = "pnlNevigator";
            this.toolTip1.SetToolTip(this.pnlNevigator, resources.GetString("pnlNevigator.ToolTip"));
            // 
            // cmdMoveFirst
            // 
            resources.ApplyResources(this.cmdMoveFirst, "cmdMoveFirst");
            this.cmdMoveFirst.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdMoveFirst, resources.GetString("cmdMoveFirst.Error"));
            this.cmdMoveFirst.ForeColor = System.Drawing.Color.Maroon;
            this.ep.SetIconAlignment(this.cmdMoveFirst, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdMoveFirst.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdMoveFirst, ((int)(resources.GetObject("cmdMoveFirst.IconPadding"))));
            this.cmdMoveFirst.Name = "cmdMoveFirst";
            this.toolTip1.SetToolTip(this.cmdMoveFirst, resources.GetString("cmdMoveFirst.ToolTip"));
            this.cmdMoveFirst.Click += new System.EventHandler(this.cmdMoveFirst_Click);
            // 
            // cmdMovePrevious
            // 
            resources.ApplyResources(this.cmdMovePrevious, "cmdMovePrevious");
            this.cmdMovePrevious.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdMovePrevious, resources.GetString("cmdMovePrevious.Error"));
            this.cmdMovePrevious.ForeColor = System.Drawing.Color.Maroon;
            this.ep.SetIconAlignment(this.cmdMovePrevious, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdMovePrevious.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdMovePrevious, ((int)(resources.GetObject("cmdMovePrevious.IconPadding"))));
            this.cmdMovePrevious.Name = "cmdMovePrevious";
            this.toolTip1.SetToolTip(this.cmdMovePrevious, resources.GetString("cmdMovePrevious.ToolTip"));
            this.cmdMovePrevious.Click += new System.EventHandler(this.cmdMovePrevious_Click);
            // 
            // cmdMoveNext
            // 
            resources.ApplyResources(this.cmdMoveNext, "cmdMoveNext");
            this.cmdMoveNext.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdMoveNext, resources.GetString("cmdMoveNext.Error"));
            this.cmdMoveNext.ForeColor = System.Drawing.Color.Maroon;
            this.ep.SetIconAlignment(this.cmdMoveNext, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdMoveNext.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdMoveNext, ((int)(resources.GetObject("cmdMoveNext.IconPadding"))));
            this.cmdMoveNext.Name = "cmdMoveNext";
            this.toolTip1.SetToolTip(this.cmdMoveNext, resources.GetString("cmdMoveNext.ToolTip"));
            this.cmdMoveNext.Click += new System.EventHandler(this.cmdMoveNext_Click);
            // 
            // cmdMoveLast
            // 
            resources.ApplyResources(this.cmdMoveLast, "cmdMoveLast");
            this.cmdMoveLast.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdMoveLast, resources.GetString("cmdMoveLast.Error"));
            this.cmdMoveLast.ForeColor = System.Drawing.Color.Maroon;
            this.ep.SetIconAlignment(this.cmdMoveLast, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdMoveLast.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdMoveLast, ((int)(resources.GetObject("cmdMoveLast.IconPadding"))));
            this.cmdMoveLast.Name = "cmdMoveLast";
            this.toolTip1.SetToolTip(this.cmdMoveLast, resources.GetString("cmdMoveLast.ToolTip"));
            this.cmdMoveLast.Click += new System.EventHandler(this.cmdMoveLast_Click);
            // 
            // lblRecordInfo
            // 
            resources.ApplyResources(this.lblRecordInfo, "lblRecordInfo");
            this.lblRecordInfo.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.ep.SetError(this.lblRecordInfo, resources.GetString("lblRecordInfo.Error"));
            this.ep.SetIconAlignment(this.lblRecordInfo, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("lblRecordInfo.IconAlignment"))));
            this.ep.SetIconPadding(this.lblRecordInfo, ((int)(resources.GetObject("lblRecordInfo.IconPadding"))));
            this.lblRecordInfo.Name = "lblRecordInfo";
            this.toolTip1.SetToolTip(this.lblRecordInfo, resources.GetString("lblRecordInfo.ToolTip"));
            // 
            // txtNgayChungTu
            // 
            resources.ApplyResources(this.txtNgayChungTu, "txtNgayChungTu");
            this.txtNgayChungTu.ClearTime = false;
            this.txtNgayChungTu.DateDelimiter = "/";
            this.txtNgayChungTu.DateInputFormat = CNCSoft.EUtilities.DateFormat.DDMMYYYY;
            this.txtNgayChungTu.DateOutputFormat = CNCSoft.EUtilities.DateFormat.DDMMYYYY;
            this.ep.SetError(this.txtNgayChungTu, resources.GetString("txtNgayChungTu.Error"));
            this.txtNgayChungTu.FieldReference = null;
            this.ep.SetIconAlignment(this.txtNgayChungTu, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtNgayChungTu.IconAlignment"))));
            this.ep.SetIconPadding(this.txtNgayChungTu, ((int)(resources.GetObject("txtNgayChungTu.IconPadding"))));
            this.txtNgayChungTu.MaskEdit = "";
            this.txtNgayChungTu.MessageLanguage = CNCSoft.EWinform.ValidText.MessageLanguages.Vietnamese;
            this.txtNgayChungTu.Name = "txtNgayChungTu";
            this.txtNgayChungTu.RegExPattern = CNCSoft.EWinform.ValidText.RegularExpressionModes.AutomatedDate;
            this.txtNgayChungTu.Required = false;
            this.txtNgayChungTu.ShowErrorIcon = true;
            this.toolTip1.SetToolTip(this.txtNgayChungTu, resources.GetString("txtNgayChungTu.ToolTip"));
            this.txtNgayChungTu.ValidationMode = CNCSoft.EWinform.ValidText.ValidationModes.None;
            this.txtNgayChungTu.ValidText = "0123456789/ ";
            this.txtNgayChungTu.YearPrefix = ((short)(20));
            // 
            // txtSoTienUSD
            // 
            resources.ApplyResources(this.txtSoTienUSD, "txtSoTienUSD");
            this.txtSoTienUSD.BackColor = System.Drawing.Color.PaleGoldenrod;
            this.ep.SetError(this.txtSoTienUSD, resources.GetString("txtSoTienUSD.Error"));
            this.txtSoTienUSD.ForeColor = System.Drawing.Color.IndianRed;
            this.ep.SetIconAlignment(this.txtSoTienUSD, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtSoTienUSD.IconAlignment"))));
            this.ep.SetIconPadding(this.txtSoTienUSD, ((int)(resources.GetObject("txtSoTienUSD.IconPadding"))));
            this.txtSoTienUSD.Name = "txtSoTienUSD";
            this.toolTip1.SetToolTip(this.txtSoTienUSD, resources.GetString("txtSoTienUSD.ToolTip"));
            this.txtSoTienUSD.TextChanged += new System.EventHandler(this.txtSoTienUSD_TextChanged);
            this.txtSoTienUSD.Validated += new System.EventHandler(this.txtSoTienUSD_Validated);
            // 
            // txtTigia
            // 
            resources.ApplyResources(this.txtTigia, "txtTigia");
            this.txtTigia.BackColor = System.Drawing.SystemColors.Window;
            this.ep.SetError(this.txtTigia, resources.GetString("txtTigia.Error"));
            this.txtTigia.ForeColor = System.Drawing.Color.IndianRed;
            this.ep.SetIconAlignment(this.txtTigia, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtTigia.IconAlignment"))));
            this.ep.SetIconPadding(this.txtTigia, ((int)(resources.GetObject("txtTigia.IconPadding"))));
            this.txtTigia.Name = "txtTigia";
            this.toolTip1.SetToolTip(this.txtTigia, resources.GetString("txtTigia.ToolTip"));
            this.txtTigia.Validated += new System.EventHandler(this.txtTigia_Validated);
            // 
            // label7
            // 
            resources.ApplyResources(this.label7, "label7");
            this.ep.SetError(this.label7, resources.GetString("label7.Error"));
            this.ep.SetIconAlignment(this.label7, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label7.IconAlignment"))));
            this.ep.SetIconPadding(this.label7, ((int)(resources.GetObject("label7.IconPadding"))));
            this.label7.Name = "label7";
            this.toolTip1.SetToolTip(this.label7, resources.GetString("label7.ToolTip"));
            // 
            // label11
            // 
            resources.ApplyResources(this.label11, "label11");
            this.ep.SetError(this.label11, resources.GetString("label11.Error"));
            this.ep.SetIconAlignment(this.label11, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label11.IconAlignment"))));
            this.ep.SetIconPadding(this.label11, ((int)(resources.GetObject("label11.IconPadding"))));
            this.label11.Name = "label11";
            this.toolTip1.SetToolTip(this.label11, resources.GetString("label11.ToolTip"));
            // 
            // txtSoTienDiscount
            // 
            resources.ApplyResources(this.txtSoTienDiscount, "txtSoTienDiscount");
            this.txtSoTienDiscount.BackColor = System.Drawing.SystemColors.Window;
            this.ep.SetError(this.txtSoTienDiscount, resources.GetString("txtSoTienDiscount.Error"));
            this.txtSoTienDiscount.ForeColor = System.Drawing.Color.IndianRed;
            this.ep.SetIconAlignment(this.txtSoTienDiscount, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtSoTienDiscount.IconAlignment"))));
            this.ep.SetIconPadding(this.txtSoTienDiscount, ((int)(resources.GetObject("txtSoTienDiscount.IconPadding"))));
            this.txtSoTienDiscount.Name = "txtSoTienDiscount";
            this.toolTip1.SetToolTip(this.txtSoTienDiscount, resources.GetString("txtSoTienDiscount.ToolTip"));
            // 
            // label12
            // 
            resources.ApplyResources(this.label12, "label12");
            this.ep.SetError(this.label12, resources.GetString("label12.Error"));
            this.ep.SetIconAlignment(this.label12, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label12.IconAlignment"))));
            this.ep.SetIconPadding(this.label12, ((int)(resources.GetObject("label12.IconPadding"))));
            this.label12.Name = "label12";
            this.toolTip1.SetToolTip(this.label12, resources.GetString("label12.ToolTip"));
            // 
            // txtPhantramDiscount
            // 
            resources.ApplyResources(this.txtPhantramDiscount, "txtPhantramDiscount");
            this.txtPhantramDiscount.BackColor = System.Drawing.SystemColors.Window;
            this.ep.SetError(this.txtPhantramDiscount, resources.GetString("txtPhantramDiscount.Error"));
            this.txtPhantramDiscount.ForeColor = System.Drawing.Color.IndianRed;
            this.ep.SetIconAlignment(this.txtPhantramDiscount, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtPhantramDiscount.IconAlignment"))));
            this.ep.SetIconPadding(this.txtPhantramDiscount, ((int)(resources.GetObject("txtPhantramDiscount.IconPadding"))));
            this.txtPhantramDiscount.Name = "txtPhantramDiscount";
            this.toolTip1.SetToolTip(this.txtPhantramDiscount, resources.GetString("txtPhantramDiscount.ToolTip"));
            this.txtPhantramDiscount.Validated += new System.EventHandler(this.txtPhantramDiscount_Validated);
            // 
            // label13
            // 
            resources.ApplyResources(this.label13, "label13");
            this.ep.SetError(this.label13, resources.GetString("label13.Error"));
            this.ep.SetIconAlignment(this.label13, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label13.IconAlignment"))));
            this.ep.SetIconPadding(this.label13, ((int)(resources.GetObject("label13.IconPadding"))));
            this.label13.Name = "label13";
            this.toolTip1.SetToolTip(this.label13, resources.GetString("label13.ToolTip"));
            // 
            // label14
            // 
            resources.ApplyResources(this.label14, "label14");
            this.ep.SetError(this.label14, resources.GetString("label14.Error"));
            this.ep.SetIconAlignment(this.label14, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label14.IconAlignment"))));
            this.ep.SetIconPadding(this.label14, ((int)(resources.GetObject("label14.IconPadding"))));
            this.label14.Name = "label14";
            this.toolTip1.SetToolTip(this.label14, resources.GetString("label14.ToolTip"));
            // 
            // ep
            // 
            this.ep.ContainerControl = this;
            resources.ApplyResources(this.ep, "ep");
            // 
            // TienMatPhieuThu
            // 
            resources.ApplyResources(this, "$this");
            this.BackColor = System.Drawing.Color.WhiteSmoke;
            this.Controls.Add(this.txtThucThu);
            this.Controls.Add(this.label14);
            this.Controls.Add(this.txtPhantramDiscount);
            this.Controls.Add(this.label13);
            this.Controls.Add(this.txtSoTienDiscount);
            this.Controls.Add(this.label12);
            this.Controls.Add(this.dgridChiTietPT);
            this.Controls.Add(this.txtSoTien);
            this.Controls.Add(this.label11);
            this.Controls.Add(this.txtTigia);
            this.Controls.Add(this.label7);
            this.Controls.Add(this.txtSoTienUSD);
            this.Controls.Add(this.txtNgayChungTu);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.txtDiaChi);
            this.Controls.Add(this.label10);
            this.Controls.Add(this.txtSoChungTu);
            this.Controls.Add(this.txtChungTuKemTheo);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.txtDienGiai);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.txtHoTenNguoiNopTien);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label9);
            this.Controls.Add(this.label8);
            this.Controls.Add(this.cmdLookupDVNopTiep);
            this.Controls.Add(this.cmdXemTK);
            this.Controls.Add(this.pnlButtons);
            this.Controls.Add(this.cboLyDoThu);
            this.Controls.Add(this.cboDonViNopTien);
            this.Controls.Add(this.pnlBottom);
            this.KeyPreview = true;
            this.Name = "TienMatPhieuThu";
            this.Tag = "";
            this.toolTip1.SetToolTip(this, resources.GetString("$this.ToolTip"));
            this.Load += new System.EventHandler(this.TienMatPhieuThu_Load);
            this.Click += new System.EventHandler(this.TienMatPhieuThu_Click);
            this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TienMatPhieuThu_KeyDown);
            this.pnlButtons.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.picboxNote)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.picboxHelp)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.dgridChiTietPT)).EndInit();
            this.pnlBottom.ResumeLayout(false);
            this.pnlNevigator.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.ep)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		#region [ Command Events ]
		    bool cancelHandlers;
		    TienMatPhieuThuData ptData;
		    BindingManagerBase bmb;
            //Cac bien phan quyen tren form
            bool DuocQuyenThem = true;
            bool DuocQuyenSua = true;
            bool DuocQuyenXoa = true;
            
		#endregion

 
		private void TienMatPhieuThu_Load(object sender, System.EventArgs e) {
			cancelHandlers = true;
			try {
				ptData = new TienMatPhieuThuData();

				intiDatabinding();

				ptData.getTable(TienMatPhieuThuData.TL.TienMatPT_CT).ColumnChanged +=new DataColumnChangeEventHandler(TienMatPhieuThu_ColumnChanged);
				ptData.getTable(TienMatPhieuThuData.TL.TienMatPT_CT).RowDeleted +=new DataRowChangeEventHandler(TienMatPhieuThu_RowDeleted);
				
				bmb = this.BindingContext[ptData.getDataSet(), "TienMatPT"];

				bmb.PositionChanged +=new EventHandler(bmb_PositionChanged);

			} catch {
				MessageBox.Show(this, RS.ERROR_LOAD_FORM, RS.ERROR_LOAD_FORM_CAPTION, 
					MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
			} finally {
				cancelHandlers = false;
			}
	        
            PublicFunction.PhanQuyenForm(this.Name, GlobalVariable.WSInfo.UserID, out DuocQuyenThem, out DuocQuyenSua, out DuocQuyenXoa);
            
            if (DuocQuyenThem)
                cmdAddNew_Click(cmdAddNew, e);
            else
            {
                setEditMode(false);
                sendStatus("Bạn không có quyền thêm mới", false);
            }
            
		}

		private void bmb_PositionChanged(object sender, System.EventArgs e) {
			if (cancelHandlers) return;

			cancelHandlers = true;
			if (bmb.Count == 0) {
				this.lblRecordInfo.Text = "0/0";
			} else {
				this.lblRecordInfo.Text = (bmb.Position +1) +"/" +bmb.Count;
			}

			if (bmb.Position >= 0) {
				buildDgridTS();
			}
			cancelHandlers = false;
		}

		private void TienMatPhieuThu_RowDeleted(object sender, DataRowChangeEventArgs e) {
			if (ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D").Length > 0) {
				this["TongTien"] = ptData.getTable(TienMatPhieuThuData.TL.TienMatPT_CT).Compute("Sum(SoTien)", "SoChungTu='" +this["SoChungTu"] +"'");
			} else {
			   this["TongTien"] = 0;
			}
			bmb.EndCurrentEdit();
		}
		private void TienMatPhieuThu_ColumnChanged(object sender, DataColumnChangeEventArgs e) {
		/*
            if (cancelHandlers) return;
			cancelHandlers = true;
            //MessageBox.Show(e.Column.ColumnName);  

			try {
                if (e.Column.ColumnName.ToUpper() == "SOTIEN" || e.Column.ColumnName.ToUpper() == "SOTIENUSD" || e.Column.ColumnName.ToUpper() == "SOTIENDISCOUNT" || e.Column.ColumnName.ToUpper() == "THUESUAT" || e.Column.ColumnName.ToUpper() == "TIGIA")
               {

					double sumSoTien = 0;
                    double sumSotienUSD = 0;
                    double sumSotienDiscount = 0;

					if (e.Row["SoTien"] is DBNull) e.Row["SoTien"] = 0;
                    if (e.Row["SotienUSD"] is DBNull) e.Row["SotienUSD"] = 0;
					if (e.Row["ThueSuat"] is DBNull) e.Row["ThueSuat"] = 0;
                    if (e.Row["SotienDiscount"] is DBNull) e.Row["SotienDiscount"] = 0;

					double thueSuat = (double)e.Row["ThueSuat"];
					double soTien = (double)(decimal)e.Row["SoTien"];
                    double sotienUSD = (double)(decimal)e.Row["SotienUSD"];
                    double SotienDiscount = (double)(decimal)e.Row["SotienDiscount"];
					
                    sumSoTien = soTien;
                    sumSotienUSD = sotienUSD;
                    sumSotienDiscount = SotienDiscount;

					if (coThue) {
						e.Row["TienThue"] =thueSuat*0.01*soTien;
					} else {
						e.Row["ThueSuat"] = 0;
						e.Row["TienThue"] = 0;
					}
					int numOfRow = ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D").Length;

					if (numOfRow > 0) {
						sumSoTien = (double)(decimal)ptData.getTable(TienMatPhieuThuData.TL.TienMatPT_CT).Compute("Sum(SoTien)", "SoChungTu='" +this["SoChungTu"] +"'");
                        sumSotienUSD = (double)(decimal)ptData.getTable(TienMatPhieuThuData.TL.TienMatPT_CT).Compute("Sum(SotienUSD)", "SoChungTu='" + this["SoChungTu"] + "'");
                        sumSotienDiscount = (double)(decimal)ptData.getTable(TienMatPhieuThuData.TL.TienMatPT_CT).Compute("Sum(SotienDiscount)", "SoChungTu='" + this["SoChungTu"] + "'");
						if (numOfRow == dgridChiTietPT.CurrentCell.RowNumber) {
							sumSoTien += soTien;
                            sumSotienUSD += sotienUSD;
                            sumSotienDiscount += SotienDiscount;
						}
					}
					this["TongTien"] = sumSoTien;
                    this["TongTienUSD"] = sumSotienUSD ;
                    this["TongtienDiscount"] = sumSotienDiscount;

                    if (numOfRow > 1) this["TiGia"] = 0; //Khi co nhieu chi tiet thi ko quan tam den tigia o master.

                    //Disable nhung textbox ko the sua neu co nhieu dong o chi tiet
                    txtSoTienUSD.Enabled = !(numOfRow > 1);
                    txtTigia.Enabled = !(numOfRow > 1);
                    txtSoTien.Enabled = !(numOfRow > 1);
                    txtPhantramDiscount.Enabled = !(numOfRow > 1);
                    txtSoTienDiscount.Enabled = !(numOfRow > 1); 
                    cboLyDoThu.Enabled = !(numOfRow > 1);
				
                    bmb.EndCurrentEdit();

				}
			} finally {
				cancelHandlers = false;
			}
         */
		}

		#region [ Commond Methods ]

		private void intiDatabinding() {
			this.txtSoChungTu.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.SoChungTu");
			this.txtNgayChungTu.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.NgayChungTu");
			this.txtNgayChungTu.ActiveDisplayFormat();
			this.txtChungTuKemTheo.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.SoChungtuKemTheo");
			this.txtDiaChi.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.DiaChi");
			this.txtDienGiai.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.DienGiai");
			this.txtHoTenNguoiNopTien.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.Hoten");

            this.txtSoTienUSD.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.TongTienUSD");
            this.txtSoTienUSD.DataBindings["Text"].Parse += new ConvertEventHandler(TienMatPhieuThu_Parse);
            this.txtSoTienUSD.DataBindings["Text"].Format += new ConvertEventHandler(TienMatPhieuThu_Format);

            this.txtTigia.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.Tigia");
            this.txtTigia.DataBindings["Text"].Parse += new ConvertEventHandler(TienMatPhieuThu_Parse);
            this.txtTigia.DataBindings["Text"].Format += new ConvertEventHandler(TienMatPhieuThu_Format);

            this.txtSoTien.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.TongTien");
			this.txtSoTien.DataBindings["Text"].Parse += new ConvertEventHandler(TienMatPhieuThu_Parse);
			this.txtSoTien.DataBindings["Text"].Format +=new ConvertEventHandler(TienMatPhieuThu_Format);

            this.txtPhantramDiscount.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.PhanTramDiscount");
            this.txtPhantramDiscount.DataBindings["Text"].Parse += new ConvertEventHandler(TienMatPhieuThu_Parse);
            this.txtPhantramDiscount.DataBindings["Text"].Format += new ConvertEventHandler(TienMatPhieuThu_Format);

            this.txtSoTienDiscount.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.TongTienDiscount");
            this.txtSoTienDiscount.DataBindings["Text"].Parse += new ConvertEventHandler(TienMatPhieuThu_Parse);
            this.txtSoTienDiscount.DataBindings["Text"].Format += new ConvertEventHandler(TienMatPhieuThu_Format);

            this.txtThucThu.DataBindings.Add("Text", ptData.getDataSet(), "TienMatPT.ThucThu");
            this.txtThucThu.DataBindings["Text"].Parse += new ConvertEventHandler(TienMatPhieuThu_Parse);
            this.txtThucThu.DataBindings["Text"].Format += new ConvertEventHandler(TienMatPhieuThu_Format);

			this.cboDonViNopTien.DataBindings.Add("SelectedValue", ptData.getDataSet(), "TienMatPT.MaDoiTac");
			this.cboDonViNopTien.DataSource = ptData.getTable(TienMatPhieuThuData.TL.DoiTac);
			this.cboDonViNopTien.DisplayMember = "TenDoiTac";
			this.cboDonViNopTien.ValueMember = "MaDoiTac";
			
			this.cboLyDoThu.DataBindings.Add("SelectedValue", ptData.getDataSet(), "TienMatPT.LyDoThuChi");
			this.cboLyDoThu.DataSource = ptData.getTable(TienMatPhieuThuData.TL.LyDoThu);
			this.cboLyDoThu.DisplayMember = "DienGiai";
			this.cboLyDoThu.ValueMember = "MaTaiKhoan";

			dgridChiTietPT.SetDataBinding(ptData.getDataSet(), "TienMatPT.M_D");
		}

		private void TienMatPhieuThu_Parse(object sender, ConvertEventArgs e) {
			try {
				if (e.Value == null || (string)e.Value == string.Empty) {
					e.Value = DBNull.Value;
				} else {
					e.Value = double.Parse((string)e.Value);
				}
			} catch {
				sendStatus("Bạn vui lòng nhập đúng định dạng số.", true);
			}
		}

		private void TienMatPhieuThu_Format(object sender, ConvertEventArgs e) {
			try {
				if (Convert.IsDBNull(e.Value)) {
					e.Value = "";
				} else {
					e.Value = ((decimal)e.Value).ToString("N");
				}
			} catch (Exception ex) {
				//sendStatus("Unexpected Error: " +ex.Message, true);  //Ko can thiet
			}
		}

		DataGridAutoResizeSupporter dgridARS = new DataGridAutoResizeSupporter();
		DataGridStyleFactory dgridSF = new DataGridStyleFactory();
		private bool coThue;
		private void buildDgridTS() {

			// Build based on LyDoThu column
			if (cboLyDoThu.SelectedIndex == -1) {
				return;
			}
			DataRow dr = ptData.getTable(TienMatPhieuThuData.TL.LyDoThu).Rows[cboLyDoThu.SelectedIndex];
			
			DataGridTableStyle ts = new DataGridTableStyle();
			ts.MappingName = ptData.getTable(TienMatPhieuThuData.TL.TienMatPT_CT).TableName;

			AGridTextBoxColumn agridTC;

			AGridMCComBoBoxColumn colLDT = new AGridMCComBoBoxColumn(ptData.getTable(TienMatPhieuThuData.TL.LyDoThu_Detail));
			colLDT.MappingName = "TaiKhoanCo";
			colLDT.HeaderText = "Tài khoản có";
			colLDT.DisplayMember = "MaTaiKhoan";
			colLDT.ValueMember = "MaTaiKhoan";
			colLDT.NullText = "";
			colLDT.Width = 100;
			ts.GridColumnStyles.Add(colLDT);
            
            //Them cot Tieu khoan co1 = Madoitac
            agridTC = new AGridTextBoxColumn();
            agridTC.MappingName = "MaTieukhoanCO1";
            agridTC.HeaderText = "Tiểu khoản";
            agridTC.NullText = "";
            agridTC.Width = 100;
            ts.GridColumnStyles.Add(agridTC);

            agridTC = new AGridTextBoxColumn();
        	agridTC.MappingName = "SoTien";
			agridTC.HeaderText = "Số tiền";
			agridTC.NullText = "";
			agridTC.Width = 100;
			agridTC.Format = "N";
			ts.GridColumnStyles.Add(agridTC);

			agridTC = new AGridTextBoxColumn();
			agridTC.MappingName = "DienGiaiChiTiet";
			agridTC.HeaderText = "Diễn giải chi tiết";
			agridTC.NullText = "";
			agridTC.Width = 300;
			agridTC.Format = "N";
			ts.GridColumnStyles.Add(agridTC);

            //Them cot TK NO
            agridTC = new AGridTextBoxColumn();
            agridTC.MappingName = "TaiKhoanNO";
            agridTC.HeaderText = "TK Nợ";
            agridTC.NullText = "";
            agridTC.Width = 100;
            agridTC.Format = "N";
            ts.GridColumnStyles.Add(agridTC);

			dgridChiTietPT.TableStyles.Clear();
			dgridChiTietPT.TableStyles.Add(ts);
			dgridSF.applyStyle(dgridChiTietPT, DataGridStyleFactory.Styles.SexyStyle);
			dgridChiTietPT.TableStyles[0].AllowSorting = false;
		}

		private void setEditMode(bool edit) {

			cmdAddNew.Enabled = !edit && DuocQuyenThem;
			cmdDelete.Enabled = !edit && bmb.Position >= 0 && DuocQuyenXoa;
			cmdModify.Enabled = !edit && bmb.Position >= 0 && DuocQuyenSua;
			cmdPrint.Enabled = !edit && bmb.Position >= 0;
			cmdView.Enabled = !edit;
			cmdUpdate.Enabled = edit;
			cmdCancel.Enabled = edit;

			cmdLookupDVNopTiep.Enabled = edit;

			cmdMoveFirst.Enabled = !edit;
			cmdMovePrevious.Enabled = !edit;
			cmdMoveNext.Enabled = !edit;
			cmdMoveLast.Enabled = !edit;

			txtSoChungTu.ReadOnly = true;
			txtNgayChungTu.ReadOnly = !edit;
			txtSoTien.ReadOnly = !edit;
			txtDiaChi.ReadOnly = !edit;
			txtDienGiai.ReadOnly = !edit;
			txtChungTuKemTheo.ReadOnly = !edit;
			txtHoTenNguoiNopTien.ReadOnly = !edit;
			cboDonViNopTien.Enabled = edit;
			cboLyDoThu.Enabled = edit;
            txtSoTienUSD.Enabled = edit;
            txtTigia.Enabled = edit;
            txtSoTien.ReadOnly = true;
            txtPhantramDiscount.Enabled = edit; 
            txtSoTienDiscount.ReadOnly  = true;

			dgridChiTietPT.ReadOnly = !edit;
			cmdXemTK.Enabled = bmb.Position >= 0;
		}

		#endregion

		#region [ Command Events ]

		private void cmdAddNew_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;

            if (ptData.createNewRow()) {
				bmb.Position = bmb.Count -1;
				setEditMode(true);
				cboDonViNopTien.Focus();
			}
			cancelHandlers= false;
			bmb_PositionChanged(bmb, e);
			sendStatus("Đang trong trạng thái thêm mới...", false);

		}

		private void cmdSave_Click(object sender, System.EventArgs e) {

            ep.Clear();
            //Kiem tra su giong nhau giua sochungtu va ngaychungtu
            if (txtNgayChungTu.getDateValue(true).Year.ToString().Substring(2, 2) != txtSoChungTu.Text.Substring(2, 2) || txtNgayChungTu.getDateValue(true).Month.ToString("00") != txtSoChungTu.Text.Substring(4, 2))
            {
                MessageBox.Show("Thời gian làm việc không đúng với ngày chứng từ \nBạn phải login vào chương trình với ngày làm việc thuộc tháng " +
                                              txtNgayChungTu.getDateValue(true).Month.ToString() + " năm " + txtNgayChungTu.getDateValue(true).Year.ToString(),
                                              "Chon sai ngay lam viec", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ep.SetError(txtSoChungTu, "Chọn lại ngày làm việc ngay ở màn hình đăng nhập ban đầu để đánh số chứng từ cho đúng");
                return;
            }
            //Kiem tra cac field can thiet
            
            if (cboDonViNopTien.SelectedIndex == -1) {
				ep.SetError(cboDonViNopTien, "Bạn vui lòng chọn đơn vị nộp tiền.");
				cboDonViNopTien.Focus();
				showEP = true;
				return;
			}
            if (cboLyDoThu.SelectedIndex == -1)
            {
                ep.SetError(cboLyDoThu, "Bạn vui lòng chọn lý do thu để hạch toán chứng từ");
                cboLyDoThu.Focus();
                showEP = true;
                return;
            }
			// dont regard to this code
			try {
				dgridChiTietPT.CurrentCell = 
					new DataGridCell(dgridChiTietPT.CurrentCell.RowNumber +1, 
					dgridChiTietPT.CurrentCell.ColumnNumber);
			} catch {}

			cancelHandlers = true;
			bmb.EndCurrentEdit();
			if (ptData.update()) {
				setEditMode(false);
                sendStatus("Đã lưu phiếu thu " + txtSoChungTu.Text  , false);
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void cmdCancel_Click(object sender, System.EventArgs e) {
			bmb.EndCurrentEdit();
            sendStatus("Bỏ qua, không cập nhật", false);
			DialogResult dr = DialogResult.Yes;
			if (ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).GetChanges() != null && 
				ptData.getTable(TienMatPhieuThuData.TL.TienMatPT_CT).GetChanges() != null) {
				dr = MessageBox.Show(this, RS.CANCEL_UPDATE, RS.CANCEL_UPDATE_CAPTION, 
					MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
			}
			
			if (dr == DialogResult.Yes) {
				cancelHandlers = true;
				ptData.getDataSet().RejectChanges();
				cancelHandlers = false;
				setEditMode(false);
				bmb_PositionChanged(bmb, e);
			}
		}

		FormView fv = null;
		private void cmdView_Click(object sender, System.EventArgs e) {
			if (fv == null) {
				fv = new FormView("Select * from TienMat WHERE MaLoaiChungTu='PT'", GlobalVariable.WSInfo.ConnectionString,
                    GlobalVariable.WSInfo.WorkingDate );
				fv.DateFilterColumns = new string[,] {{"NgayChungTu", "Ngày chứng từ"}, {"UpdateDate", "Ngày cập nhật"}};
                //fv.CollumnFocusInFilterGrid = 4;
			}
			fv.ShowDialog(this);
			if (fv.DialogResult == DialogResult.OK) {
				cancelHandlers = true;
				ptData.initData(fv.SelectedIDs, false);
				setEditMode(false);
				cancelHandlers = false;
				bmb_PositionChanged(bmb, e);
			}			
		}

		private void cmdModify_Click(object sender, System.EventArgs e) {
			if (bmb.Position >= 0) {
				bmb.EndCurrentEdit();
				setEditMode(true);
                sendStatus("Đang trong trạng sửa phiếu thu " + txtSoChungTu.Text  , false);
				if (ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D").Length > 1) {
					//
                    dgridChiTietPT.Visible = false ;
                    this.Size = this.MinimumSize;
                    cmdXemTK_Click(cmdXemTK, e);
                    //Disable nhung textbox ko the sua neu co nhieu dong o chi tiet
                    txtSoTienUSD.Enabled = false;
                    txtTigia.Enabled = false;
                    txtSoTien.Enabled = false;
                    txtPhantramDiscount.Enabled = false;
                    txtSoTienDiscount.Enabled = false; 
                    cboLyDoThu.Enabled = false; 
				}
			}
		}

		private void cmdDelete_Click(object sender, System.EventArgs e) {
			DialogResult dr = MessageBox.Show(this, RS.DELETE_RECORD, RS.DELETE_RECORD_CAPTION, 
				MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
			if (dr == DialogResult.Yes) {
				cancelHandlers = true;

                //Luu vet (Deleted)
                try
                {
                    SQLHelper.ExecuteScalar(GlobalVariable.WSInfo.ConnectionString, "insert into Tienmat_Deleted select * from TienMat " +
                                                                                "where sochungtu = '" + txtSoChungTu.Text + "'");
                }
                catch { };

				bmb.RemoveAt(bmb.Position);
				ptData.update();
				cancelHandlers = false;
				bmb_PositionChanged(bmb, e);
			}
		}

		private void cmdPrint_Click(object sender, System.EventArgs e) {
            //Load report
            ReportDocument rpt = new ReportDocument();
            rpt.Load(Application.StartupPath + "\\Report\\rpt_TienMat_PhieuThu.rpt");

            //Set connection
            PublicFunction.SetDBLogonForReport(rpt);

            //Set parameter
            PublicFunction.SetParameter(rpt, "@Sochungtu", txtSoChungTu.Text);
            PublicFunction.SetParameter(rpt, "pBangchu", ReportUtilities.ReportUtilities.g_Trans_VietNam(Double.Parse(txtSoTien.Text), "đồng", true));
            PublicFunction.SetParameter(rpt, "pNguoilapbieu", GlobalVariable.WSInfo.UserName);
            PublicFunction.SetParameter(rpt, "pThuquy", GlobalVariable.WSInfo["Sys.UserName.Thuquy"]);
            PublicFunction.SetParameter(rpt, "pKetoantruong", GlobalVariable.WSInfo["Sys.UserName.KetoanTruong"]);
            PublicFunction.SetParameter(rpt, "pGiamDoc", GlobalVariable.WSInfo["Sys.UserName.Giamdoc"]);

            //View report
            frmPrintPreview frmPP = new frmPrintPreview(rpt);
            frmPP.ShowDialog();
            frmPP.Dispose();

            rpt.Dispose();
		}


		#endregion

        private void cmdXemTK_Click(object sender, System.EventArgs e) {
			if (!cmdAddNew.Enabled && cboLyDoThu.SelectedIndex == -1) {
				ep.SetError(cboLyDoThu, "Bạn vui lòng chọn lý do thu !.");
				cboLyDoThu.Focus();
				showEP = true;
				return;
			}
            
            /*
            if (!cmdAddNew.Enabled && txtSoTienUSD.Text.Trim() == "0")
            {
                ep.SetError(txtSoTienUSD, "Bạn vui lòng nhập số tiền USD !.");
                txtSoTienUSD.Focus();
                showEP = true;
                return;
            }
            if (!cmdAddNew.Enabled && txtTigia.Text.Trim() == "0")
            {
                ep.SetError(txtTigia, "Bạn vui lòng nhập ti gia !.");
                txtTigia.Focus();
                showEP = true;
                return;
            }
            */
             
            if (!cmdAddNew.Enabled && txtSoTien.Text.Trim() == "0") {
				ep.SetError(txtSoTien, "Bạn vui lòng nhập số tiền !.");
				txtSoTien.Focus();
				showEP = true;
				return;
			}
			if (!cmdAddNew.Enabled && cboDonViNopTien.SelectedIndex == -1) {
				ep.SetError(cboDonViNopTien, "Bạn vui lòng chọn đơn vị nộp tiền !.");
				cboDonViNopTien.Focus();
				showEP = true;
				return;
			}


			dgridChiTietPT.Visible = !dgridChiTietPT.Visible;
			if (dgridChiTietPT.Visible) {
				this.Height += 120;
         	} else {
				this.Size = this.MinimumSize;
				this.WindowState = FormWindowState.Normal;
			}
		}


        bool showEP = false;

	
        
        private void txtSoTienUSD_TextChanged(object sender, System.EventArgs e) {
            if (showEP)
            {
                ep.SetError(txtSoTienUSD, null);
            }
        }

		private void txtSoTien_TextChanged(object sender, System.EventArgs e) {
			if (showEP) {
				ep.SetError(txtSoTien, null);
			}
		}

		private void TienMatPhieuThu_Click(object sender, System.EventArgs e) {
			cancelHandlers = false;
		}

		private object this[string colName] {
			get { return ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).Rows[bmb.Position][colName]; }
			set { ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).Rows[bmb.Position][colName] = value; }
		}

		
		FormView lookupDVNT;
		private void cmdLookupDVNopTiep_Click(object sender, System.EventArgs e) {
			if (lookupDVNT == null) lookupDVNT = new FormView("Select MaDoiTac as [Mã đối tác], TenDoiTac as [Tên đối tác], NguoiDaiDien as [Người đại diện], DiaChi as [Địa chỉ] from DM_DoiTac", GlobalVariable.WSInfo.ConnectionString);
			lookupDVNT.SelectionMode = SelectionMode.One;
			lookupDVNT.addCreateNewAbility("Danh mục Đối tác", GlobalVariable.WSInfo.UserID);
            //lookupDVNT.CollumnFocusInFilterGrid = 1;
			lookupDVNT.ShowDialog(this);
			if (lookupDVNT.DialogResult == DialogResult.OK) {
				cboDonViNopTien.SelectedValue = lookupDVNT.SelectedIDs.Replace("('", "").Replace("')","");
				bmb.EndCurrentEdit();
			}
		}

		private void TienMatPhieuThu_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) {
			if (e.KeyCode == Keys.Enter) {
				this.SelectNextControl(this.ActiveControl, true, true, true, true);
			} else if (e.KeyCode == Keys.Escape) {
				this.SelectNextControl(this.ActiveControl, true, false, true, true);
			}
		}

		private void cmdMoveFirst_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;
			if (bmb != null && bmb.Count > 0) {
				bmb.Position = 0;
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void cmdMovePrevious_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;
			if (bmb != null && bmb.Position > 0) {
				bmb.Position -= 1;
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void cmdMoveLast_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;
			if (bmb != null && bmb.Count > 0) {
				bmb.Position = bmb.Count -1;
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void cmdMoveNext_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;
			if (bmb != null && bmb.Position < bmb.Count -1) {
				bmb.Position += 1;
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void sendStatus(string msg) {
			sendStatus(msg, false);
		}

		private void picboxHelp_Click(object sender, System.EventArgs e) {
		
		}

		private void cmdNote_Click(object sender, System.EventArgs e) {
			SimpleObjectNote son = new SimpleObjectNote(GlobalVariable.WSInfo.ConnectionString,
				this.Text, GlobalVariable.WSInfo.UserID);
			son.ShowDialog(this);
		}
	
		private void sendStatus(string msg, bool error) {
			if (error) {
				lblStatus.ForeColor = Color.Red;
				lblStatus.Text = msg;
			} else {
				lblStatus.ForeColor = Color.Black;
				lblStatus.Text = msg;
			}
		}


        private void txtSoTienUSD_Validated(object sender, EventArgs e)
        {
            TinhToanCacKieuTien();
        }

        private void txtTigia_Validated(object sender, EventArgs e)
        {
            TinhToanCacKieuTien();
        }


        private void txtSoTien_Validated(object sender, EventArgs e) 
        {
            TinhToanCacKieuTien();           
        }

    
        private void txtDienGiai_Leave(object sender, EventArgs e)
        {
            cmdUpdate.Focus(); 
        }

      
        private void txtDienGiai_Validated(object sender, EventArgs e)
        {
            ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D")[0]["DienGiaiChiTiet"] = txtDienGiai.Text;
        }

 
        private void txtPhantramDiscount_Validated(object sender, EventArgs e)
        {
            TinhToanCacKieuTien();
        }

        private void cboLyDoThu_Validated(object sender, EventArgs e)
        {

            if (cboLyDoThu.SelectedIndex == -1)
            {
                return;
            }
            txtDienGiai.Text = ((string)txtDienGiai.Tag).Replace("<LyDoThu>", cboLyDoThu.Text).Replace("<TenDonVi>", cboDonViNopTien.Text);
            // Gán tài khoản có mặc định cho detail
            try
            {
                if (ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D").Length == 0)
                {
                    // Add a default row to detail
                    DataRow dr = ptData.getTable(TienMatPhieuThuData.TL.TienMatPT_CT).NewRow();
                    dr["SoChungTu"] = txtSoChungTu.Text;
                    dr["TaikhoanCo"] = cboLyDoThu.SelectedValue;
                    dr["MaTieukhoanCo1"] = cboDonViNopTien.SelectedValue;
                    dr["SoTien"] = Double.Parse(txtSoTien.Text);
                    dr["DienGiaiChiTiet"] = txtDienGiai.Text;
                    ptData.getTable(TienMatPhieuThuData.TL.TienMatPT_CT).Rows.Add(dr);
                }
                else if (ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D").Length == 1)
                {
                    ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D")[0]["MaTieuKhoanCo1"] = cboDonViNopTien.SelectedValue;
                    ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D")[0]["TaiKhoanCo"] = cboLyDoThu.SelectedValue;
                    ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D")[0]["SoTien"] = Double.Parse(txtSoTien.Text);
                    ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D")[0]["DienGiaiChiTiet"] = txtDienGiai.Text;
                }

                bmb.EndCurrentEdit();
            } catch (Exception ex) {
				sendStatus("Unexpected Error: " +ex.Message, true);
			}
            cancelHandlers = true;

            cboLyDoThu.Tag = cboLyDoThu.SelectedIndex;

            buildDgridTS();

            cancelHandlers = false; cancelHandlers = false;

        }


        private void TinhToanCacKieuTien()
        {
            try
            {
                Double dblSotienNguyenTe, dblTiGia, dblSoTienQuiDoi, dblPhanTramDiscount, dblSoTienDiscount, dblSoTienThucThu;
                dblSotienNguyenTe = double.Parse(txtSoTienUSD.Text);
                dblTiGia = double.Parse(txtTigia.Text);
                dblSoTienQuiDoi = double.Parse(txtSoTien.Text);
                dblPhanTramDiscount = double.Parse(txtPhantramDiscount.Text);
                dblSoTienDiscount = double.Parse(txtSoTienDiscount.Text);
                dblSoTienThucThu = double.Parse(txtThucThu.Text);

                dblSoTienQuiDoi = dblSotienNguyenTe * dblTiGia;
                dblSoTienDiscount = dblSoTienQuiDoi * dblPhanTramDiscount / 100;
                dblSoTienThucThu = dblSoTienQuiDoi - dblSoTienDiscount;

                //Gan tro lai cho cac control
                txtSoTien.Text = dblSoTienQuiDoi.ToString("N");
                txtSoTienDiscount.Text = dblSoTienDiscount.ToString("N");
                txtThucThu.Text = dblSoTienThucThu.ToString("N");

                //Gan so tien xuong cho luoi
                ptData.getTable(TienMatPhieuThuData.TL.TienMatPT).Rows[bmb.Position].GetChildRows("M_D")[0]["SoTien"] =
                    Double.Parse(txtThucThu.Text);
            }
            catch { }
        }

        private void cboDonViNopTien_SelectedIndexChanged(object sender, EventArgs e)
        {
            /*
            if (cboDonViNopTien.SelectedIndex == -1) return;
            cancelHandlers = true;
            int index = cboDonViNopTien.SelectedIndex;
            txtHoTenNguoiNopTien.Text = ((DataRowView)cboDonViNopTien.Items[index])["NguoiDaiDien"].ToString();
            txtDiaChi.Text = ((DataRowView)cboDonViNopTien.Items[index])["DiaChi"].ToString();
            txtDienGiai.Text = ((string)txtDienGiai.Tag).Replace("<LyDoThu>", cboLyDoThu.Text).Replace("<TenDonVi>", cboDonViNopTien.Text);
            //bmb.EndCurrentEdit();
            cancelHandlers = false;
             */
        }

        private void cboDonViNopTien_KeyDown(object sender, KeyEventArgs e)
        {
            /*
            if ((cboDonViNopTien.SelectedIndex == -1 && e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.F3))
            {
                cmdLookupDVNopTiep_Click(cmdLookupDVNopTiep, e);
            }
             */
        }

        
	}
}